﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Teradata.Client.Provider;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Text;
using Microsoft.VisualBasic;



public partial class UserControls_RollUpReport : System.Web.UI.UserControl
{
    private String _TopLevel = String.Empty;

    public String TopLevel
    {
        get { return _TopLevel; }
        set { _TopLevel = value; }
    }

    private String _RollUpUnit = String.Empty;

    public String RollUpUnit
    {
        get { return _RollUpUnit; }
        set { _RollUpUnit = value; }
    }

    private string _RollupTitle = String.Empty;

    public string RollupTitle
    {
        get { return _RollupTitle; }
        set { _RollupTitle = value; }
    }



    protected String SQL = String.Empty, SQL2 = String.Empty;
    protected String[] Months = { "Joe", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
    protected String HEAD1 = String.Empty, HEAD2 = String.Empty, HEAD12 = String.Empty, HEAD22 = String.Empty;
    protected String IPTV_IN = String.Empty, IPTV_OUT = String.Empty, IPTV_NET = String.Empty;
    protected String HSIA_IN = String.Empty, HSIA_OUT = String.Empty, HSIA_NET = String.Empty;
    protected String VOIP_IN = String.Empty, VOIP_OUT = String.Empty, VOIP_NET = String.Empty;
    protected String IPTV_IN2 = String.Empty, IPTV_OUT2 = String.Empty, IPTV_NET2 = String.Empty;
    protected String HSIA_IN2 = String.Empty, HSIA_OUT2 = String.Empty, HSIA_NET2 = String.Empty;
    protected String VOIP_IN2 = String.Empty, VOIP_OUT2 = String.Empty, VOIP_NET2 = String.Empty;
    protected Int32 ColCNt = 0;
    protected Int32 IPTV_IN_CNT = 0, IPTV_OUT_CNT = 0, IPTV_NET_CNT = 0;
    protected Int32 HSIA_IN_CNT = 0, HSIA_OUT_CNT = 0, HSIA_NET_CNT = 0;
    protected Int32 VOIP_IN_CNT = 0, VOIP_OUT_CNT = 0, VOIP_NET_CNT = 0;
    protected Int32 IPTV_IN_CNT2 = 0, IPTV_OUT_CNT2 = 0, IPTV_NET_CNT2 = 0;
    protected Int32 HSIA_IN_CNT2 = 0, HSIA_OUT_CNT2 = 0, HSIA_NET_CNT2 = 0;
    protected Int32 VOIP_IN_CNT2 = 0, VOIP_OUT_CNT2 = 0, VOIP_NET_CNT2 = 0;
    //protected String DwellingFilter = String.Empty, NationalFilterStr = String.Empty;
    protected String SQLFilter = String.Empty;
    protected String Chart1SQL;
    protected String Chart1PriorMonthSQL = string.Empty;
    protected String Chart2SQL;
    protected String LocationsFilter = " AND LOCATION IS {0} NULL";
    protected String ProductsFilter = " AND PRODUCT IS {0}  NULL";
    protected String DwellingsFilter = " AND DWELLING IS {0}  NULL";
    protected String LegendText = "";

    //protected String ConnString = ConfigurationManager.ConnectionStrings["EDW_GROUP_ID"].ConnectionString;


    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime startTime = DateTime.Now; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Started");


        String ManagerLevel = String.Empty;
        String RollUpFilter = String.Empty;

        if (Request.Params.Get("__EVENTTARGET") != null)
        {
            switch (Request.Params.Get("__EVENTTARGET"))
            {
                case "MouseLeftButton_Clicked":
                    Chart2_MouseLeftButton_Clicked(Request.Params.Get("__EVENTARGUMENT").Split(','));
                    break;
                default:
                    break;
            }
        }

        string TopLevelFilter = String.Format("{1}='{0}'", RollUpUnit.Replace("'", "''"), TopLevel);
        String[] tmpArr = RollUpUnit.Split(':');
        string RollUpMgr = tmpArr[0];
        ManagerLevel = tmpArr.Length == 1 ? "2" : tmpArr[1];

        switch (TopLevel)
        {
            case "Manager":



                switch (ManagerLevel)
                {
                    case "1":
                        ////SQLFilter = String.Format(" B.TRAC_ID IN (SELECT TRAC_ID FROM MIS.ACC_TRAC_INFO WHERE AREA_MGR='{0}' GROUP BY 1)", RollUpFilter);
                        //TopLevelFilter = String.Format("AREA_MGR='{0}'", RollUpMgr.Replace("'", "''"));
                        //RollUpFilter = TopLevelFilter.Split('=')[0];
                        TopLevelFilter = String.Format("MARKET='{0}'", RollUpMgr.Replace("'", "''"));
                        RollUpFilter = RollUpMgr;
                        RollupTitle = RollUpFilter;
                        break;

                    case "2":
                        //SQLFilter = String.Format(" B.TRAC_ID IN (SELECT TRAC_ID FROM MIS.ACC_TRAC_INFO WHERE ACCT_MGR='{0}' GROUP BY 1)", RollUpFilter);
                        TopLevelFilter = String.Format("ACCT_MGR='{0}'", RollUpMgr.Replace("'", "''"));
                        RollUpFilter = TopLevelFilter.Split('=')[0];
                        break;

                    case "0":
                        //RollUpFilter = ConfigurationManager.AppSettings[RollUpMgr];
                        ////SQLFilter = String.Format(" B.REGION='{0}'", RollUpFilter);
                        //RollupTitle = RollUpFilter;
                        //TopLevelFilter = String.Format("REGION='{0}'", RollUpFilter.Replace("'", "''"));
                        TopLevelFilter = String.Format("REGION='{0}'", RollUpMgr.Replace("'", "''"));
                        RollUpFilter = RollUpMgr;
                        RollupTitle = RollUpFilter;
                        break;

                    default:
                        break;
                }
                //Heading1.Text = RollUpMgr + " ROLL UP";
                break;

            case "State":
            switch (ManagerLevel)
            {
                     case "0":
                     case "1":
                        TopLevelFilter = String.Format("REGION='{0}'", RollUpMgr.Replace("'", "''"));
                        RollUpFilter = RollUpMgr;
                        //RollupTitle = RollUpFilter;
                        break;                
            }

            
            //if (RollUpUnit == "ZZ")
                //{
                //    RollUpFilter = ConfigurationManager.AppSettings[RollUpUnit];
                //    //SQLFilter = String.Format(" B.REGION='{0}'", RollUpFilter);
                //    RollupTitle = RollUpFilter;
                //    TopLevelFilter = String.Format("REGION='{0}'", RollUpFilter.Replace("'", "''"));
                //}
                ////SQLFilter = String.Format(" SUBSTR(B.TRAC_ID,1,2) = '{0}'", RollUpUnit);
                ////Heading1.Text = (String)((Hashtable)Cache["ACC_STATES"])[RollUpUnit] + " ROLL UP";
                ////Heading1.Text = RollUpUnit + " ROLL UP";
                break;

            case "Market":
                  switch (ManagerLevel)
                {
                      case "0":
                        TopLevelFilter = String.Format("REGION='{0}'", RollUpMgr.Replace("'", "''"));
                        RollUpFilter = RollUpMgr;
                        RollupTitle = RollUpFilter;
                        break;                   
                }              
            
                //SQLFilter = String.Format(" B.TRAC_ID IN (SELECT TRAC_ID FROM MIS.ACC_TRAC_INFO WHERE MARKET='{0}')", RollUpUnit);
                //Heading1.Text = RollUpUnit.ToUpper() + " ROLL UP";
                break;

            case "Portfolio":
                //SQLFilter = String.Format(" B.TRAC_ID IN (SELECT TRAC_ID FROM MIS.ACC_TRAC_INFO WHERE PORTFOLIO='{0}')", RollUpUnit);
                //Heading1.Text = RollUpUnit.ToUpper() + " ROLL UP";
                break;

            case "Property":
                //SQLFilter = String.Format(" B.TRAC_ID ='{0}'", RollUpUnit);
                TopLevelFilter = String.Format("TRAC_ID='{0}'", RollUpUnit);
                //Heading1.Text = RollUpUnit.ToUpper() + " ROLL UP";
                break;

            default:
                break;
        }

        Heading1.Text = Strings.StrConv(RollupTitle, Constants.vbProperCase, 0);

        RollupMetadata meta = (RollupMetadata)Session["RollupMetadata"];
        if (meta == null)
            Response.Redirect("about.aspx");
        else
        {
            LegendText = meta.LegendText;
            Chart1SQL = TopLevelFilter + meta.DateFilter + " ORDER BY YR, MN, DY";
            Chart1PriorMonthSQL = TopLevelFilter + " AND PRODUCT IS NULL AND LOCATION IS NULL AND DWELLING IS NULL" + meta.PriorMonthDateFilter;
            Chart2SQL = TopLevelFilter + meta.RollupFilter + " ORDER BY PRODUCT, LOCATION, DWELLING, YR, MN"; //+ (RowFilter.StartsWith("REGION") ? DwellingsFilter + ProductsFilter + LocationsFilter : "");

            FilterDataTable1(Server.UrlEncode(Chart1SQL), meta.MonthsPrior.ToString());
            FilterDataTable2(Server.UrlEncode(Chart2SQL));

            if (meta.MonthsPrior > 0)
                litMonth.Text = "&nbsp;&mdash;&nbsp;" + meta.SalesMonth;
            else
                litMonth.Text = "";
            meta.ChkStacked.Checked = true;
            meta.chkShowTables.Checked = true;

            tdChartDaily.Style["display"] = meta.ChkStacked.Checked ? "" : "none";
            tdChartMonthly.Style["display"] = meta.ChkStacked.Checked ? "" : "none";
            pnlDailyMTD.Style["display"] = meta.chkShowTables.Checked ? "" : "none";
            pnlMonthly.Style["display"] = meta.chkShowTables.Checked ? "" : "none";
            pnlSummary.Style["display"] = meta.chkShowSummary.Checked ? "" : "none";

            tdChartDaily.Style["visibility"] = meta.ChkStacked.Checked ? "visible" : "hidden";
            tdChartMonthly.Style["visibility"] = meta.ChkStacked.Checked ? "visible" : "hidden";
            pnlDailyMTD.Style["visibility"] = meta.chkShowTables.Checked ? "visible" : "hidden";
            pnlMonthly.Style["visibility"] = meta.chkShowTables.Checked ? "visible" : "hidden";
            pnlSummary.Style["visibility"] = meta.chkShowSummary.Checked ? "visible" : "hidden";
        }
        //litProductSales.Text += "<br /><font color='Blue'>(" + Chart2SQL + ")<S/font>";

        //}

        DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Ended: " + duration.ToString());
    }

    protected void Chart2_MouseLeftButton_Clicked(string[] psaArgs)
    {
        RollupMetadata meta = (RollupMetadata)Session["RollupMetadata"];
        string sRawDate = psaArgs[0].Replace(" '", "/1/20");
        DateTime dtClicked = Convert.ToDateTime(sRawDate);
        meta.MonthsPrior = (int)DateAndTime.DateDiff(DateInterval.Month, dtClicked, ((DateTime)HttpContext.Current.Session["SalesDate"]),
         Microsoft.VisualBasic.FirstDayOfWeek.Monday, Microsoft.VisualBasic.FirstWeekOfYear.Jan1);
        meta.RefreshDate();

        string[] saDimensions = psaArgs[1].Split(' ');
        meta.RefreshDimensions(saDimensions);

    }

    protected String WeekendClass(Int32 MN, Int32 DY)
    {
        DateTime startTime = DateTime.Now; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Started");
        String retstr = String.Empty;
        switch (Convert.ToInt16(new DateTime(DateTime.Today.Year, MN, DY).DayOfWeek))
        {
            case 0:
                retstr = "2";
                break;
            case 6:
                retstr = "2";
                break;
            default:
                break;

        }

        DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Ended: " + duration.ToString());
        return retstr;
    }

    protected void FilterDataTable1(String pRowFilter, string OFFSET)
    {
        DateTime startTime = DateTime.Now; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Started");

        string RowFilter = Server.UrlDecode(pRowFilter);

        string ROLLUPTYPE = RowFilter.Split('=')[0].Trim();
        //RowFilter = RowFilter.Replace("='ZZ'", " IS NULL");

        if (ROLLUPTYPE != null)
        {
            DataView dv = (new RolledUpBiz(ROLLUPTYPE)).DailyTableData(RowFilter, OFFSET);
            for (int i = 0; i < dv.Count; i++)
            {
                //sb1.Append(String.Format("    <vc:DataPoint AxisXLabel=\"{1} {0}\" YValue=\"{2}\" />",
                //    dt.DefaultView[i].Row["DY"],
                HEAD1 += "<td class=\"m" +
                    WeekendClass(
                        (int)dv[i].Row["MN"],
                        (int)dv[i].Row["DY"]) + "\">" + Months[(int)dv[i].Row["MN"]] + "</td>";
                HEAD2 += "<td class=\"d" +
                    WeekendClass(
                        (int)dv[i].Row["MN"],
                        (int)dv[i].Row["DY"]) + "\">" + ((int)dv[i].Row["DY"]).ToString() + "</td>";
                IPTV_IN += "<td class=\"n2\">" + ((int)dv[i].Row["IPTV_IN"]).ToString("n0") + "</td>";
                IPTV_IN_CNT += (int)dv[i].Row["IPTV_IN"];
                IPTV_OUT += "<td class=\"n2\">" + ((int)dv[i].Row["IPTV_OUT"]).ToString("n0") + "</td>";
                IPTV_OUT_CNT += (int)dv[i].Row["IPTV_OUT"];
                IPTV_NET += "<td class=\"n2\">" + ((int)dv[i].Row["IPTV_NET"]).ToString("n0") + "</td>";
                IPTV_NET_CNT += (int)dv[i].Row["IPTV_NET"];
                HSIA_IN += "<td class=\"n1\">" + ((int)dv[i].Row["HSIA_IN"]).ToString("n0") + "</td>";
                HSIA_IN_CNT += (int)dv[i].Row["HSIA_IN"];
                HSIA_OUT += "<td class=\"n1\">" + ((int)dv[i].Row["HSIA_OUT"]).ToString("n0") + "</td>";
                HSIA_OUT_CNT += (int)dv[i].Row["HSIA_OUT"];
                HSIA_NET += "<td class=\"n1\">" + ((int)dv[i].Row["HSIA_NET"]).ToString("n0") + "</td>";
                HSIA_NET_CNT += (int)dv[i].Row["HSIA_NET"];
                VOIP_IN += "<td class=\"n3\">" + ((int)dv[i].Row["VOIP_IN"]).ToString("n0") + "</td>";
                VOIP_IN_CNT += (int)dv[i].Row["VOIP_IN"];
                VOIP_OUT += "<td class=\"n3\">" + ((int)dv[i].Row["VOIP_OUT"]).ToString("n0") + "</td>";
                VOIP_OUT_CNT += (int)dv[i].Row["VOIP_OUT"];
                VOIP_NET += "<td class=\"n3\">" + ((int)dv[i].Row["VOIP_NET"]).ToString("n0") + "</td>";
                VOIP_NET_CNT += (int)dv[i].Row["VOIP_NET"];
                ColCNt++;
            }

        }

        DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Ended: " + duration.ToString());
    }

    protected void FilterDataTable2(String pRowFilter)
    {
        DateTime startTime = DateTime.Now; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Started");

        string RowFilter = Server.UrlDecode(pRowFilter);

        string ROLLUPTYPE = RowFilter.Split('=')[0].Trim();
        //RowFilter = RowFilter.Replace("='ZZ'", " IS NULL");

        if (ROLLUPTYPE != null)
        {
            DataView dv = (new RolledUpBiz(ROLLUPTYPE)).MonthlyTableData(RowFilter);

            ///todo Need to sum all the dvs first, th
            for (int i = 0; i < dv.Count; i++)
            {
                HEAD12 += "<td class=\"y\">" + ((int)dv[i].Row["YR"]).ToString() + "</td>";
                HEAD22 += "<td class=\"d\">" + Months[((int)dv[i].Row["MN"])] + "</td>";
                IPTV_IN2 += "<td class=\"n2\">" + ((int)dv[i].Row["IPTV_IN"]).ToString("n0") + "</td>";
                IPTV_OUT2 += "<td class=\"n2\">" + ((int)dv[i].Row["IPTV_OUT"]).ToString("n0") + "</td>";
                IPTV_NET2 += "<td class=\"n2\">" + ((int)dv[i].Row["IPTV_NET"]).ToString("n0") + "</td>";
                HSIA_IN2 += "<td class=\"n1\">" + ((int)dv[i].Row["HSIA_IN"]).ToString("n0") + "</td>";
                HSIA_OUT2 += "<td class=\"n1\">" + ((int)dv[i].Row["HSIA_OUT"]).ToString("n0") + "</td>";
                HSIA_NET2 += "<td class=\"n1\">" + ((int)dv[i].Row["HSIA_NET"]).ToString("n0") + "</td>";
                VOIP_IN2 += "<td class=\"n3\">" + ((int)dv[i].Row["VOIP_IN"]).ToString("n0") + "</td>";
                VOIP_OUT2 += "<td class=\"n3\">" + ((int)dv[i].Row["VOIP_OUT"]).ToString("n0") + "</td>";
                VOIP_NET2 += "<td class=\"n3\">" + ((int)dv[i].Row["VOIP_NET"]).ToString("n0") + "</td>";
            }

        }
        DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Ended: " + duration.ToString());
    }

    //for (int i = 0; i < dv.Count; i++)
    //{
    //    IPTV_IN_CNT2 += (int)dv[i].Row["IPTV_IN"]; IPTV_OUT_CNT2 += (int)dv[i].Row["IPTV_OUT"]; IPTV_NET_CNT2 += (int)dv[i].Row["IPTV_NET"];
    //    HSIA_IN_CNT2 += (int)dv[i].Row["HSIA_IN"]; HSIA_OUT_CNT2 += (int)dv[i].Row["HSIA_OUT"]; HSIA_NET_CNT2 += (int)dv[i].Row["HSIA_NET"];
    //    VOIP_IN_CNT2 += (int)dv[i].Row["VOIP_IN"]; VOIP_OUT_CNT2 += (int)dv[i].Row["VOIP_OUT"]; VOIP_NET_CNT2 += (int)dv[i].Row["VOIP_NET"];
    //}
    //HEAD12 += "<td class=\"y\">" + ((int)dv[0].Row["YR"]).ToString() + "</td>";
    //HEAD22 += "<td class=\"d\">" + Months[((int)dv[0].Row["MN"])] + "</td>";
    //IPTV_IN2 += "<td class=\"n1\">" + (IPTV_IN_CNT2).ToString("n0") + "</td>";
    //IPTV_OUT2 += "<td class=\"n1\">" + (IPTV_OUT_CNT2).ToString("n0") + "</td>";
    //IPTV_NET2 += "<td class=\"n1\">" + (IPTV_NET_CNT2).ToString("n0") + "</td>";
    //HSIA_IN2 += "<td class=\"n2\">" + (HSIA_IN_CNT2).ToString("n0") + "</td>";
    //HSIA_OUT2 += "<td class=\"n2\">" + (HSIA_OUT_CNT2).ToString("n0") + "</td>";
    //HSIA_NET2 += "<td class=\"n2\">" + (HSIA_NET_CNT2).ToString("n0") + "</td>";
    //VOIP_IN2 += "<td class=\"n3\">" + (VOIP_IN_CNT2).ToString("n0") + "</td>";
    //VOIP_OUT2 += "<td class=\"n3\">" + (VOIP_OUT_CNT2).ToString("n0") + "</td>";
    //VOIP_NET2 += "<td class=\"n3\">" + (VOIP_NET_CNT2).ToString("n0") + "</td>";

    protected void myFilter_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected String getJScriptText1()
    {
        RollupMetadata meta = (RollupMetadata)Session["RollupMetadata"];

        /////pnlDailyMTD.Visible = !meta.DisplayMonthly();
        //pnlChartDaily.Style["display"] = pnlDailyMTD.Visible ? "" : "none";

        string sHeight = (meta.DisplayDaily() ? "480" : meta.DisplayBoth() ? "300" : "0");
        string sWidth = (meta.DisplayDaily() ? "800" : meta.DisplayBoth() ? "500" : "0");

        DateTime startTime = DateTime.Now; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Started");
        StringBuilder sb = new StringBuilder();
        sb.Length = 0;
        sb.Append("    <script language=\"javascript\" type=\"text/javascript\">" + Environment.NewLine);
        sb.Append("      var vChart = new Visifire2(\"SL.Visifire.Charts.xap\"," + sWidth + "," + sHeight + ");" + Environment.NewLine);
        if (meta.DailyChartStyle == "Pacing")
            sb.Append("      vChart.setDataUri(\"getChartData.aspx?SQLFILTER=" + Server.UrlEncode(Chart1SQL) + "&OFFSET=" + "0" + "&PRIORMONTH=" + Server.UrlEncode(Chart1PriorMonthSQL) + "\");" + Environment.NewLine);
        else
            sb.Append("      vChart.setDataUri(\"getChartData.aspx?SQLFILTER=" + Server.UrlEncode(Chart1SQL) + "&OFFSET=" + "0" + "\");" + Environment.NewLine);
        sb.Append("      vChart.render(\"VisifireChart1\");" + Environment.NewLine);
        if (meta.DisplayMonthly()) sb.Append("      ShowChartDaily(false) " + Environment.NewLine);
        sb.Append("    </" + "script>" + Environment.NewLine);
        DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Ended: " + duration.ToString()); return sb.ToString();
    }


    protected String getJScriptText2()
    {
        DateTime startTime = DateTime.Now; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Started");

        RollupMetadata meta = (RollupMetadata)Session["RollupMetadata"];

        /////pnlMonthly.Style["display"] = !meta.DisplayDaily() ? "" : "none";
        //pnlChartMonthly.Style["display"] = pnlMonthly.Visible ? "" : "none";

        string sHeight = (meta.DisplayMonthly() ? "480" : "300");
        string sWidth = (meta.DisplayMonthly() ? "800" : "500");

        StringBuilder sb = new StringBuilder();
        sb.Length = 0;
        sb.Append("    <script language=\"javascript\" type=\"text/javascript\">" + Environment.NewLine);
        sb.Append("function MouseLeftButton_Clicked(sender, eventArgs){ __doPostBack(\"MouseLeftButton_Clicked\", sender.AxisXLabel + ',' + sender.LegendText)}" + Environment.NewLine);
        sb.Append("      var vChart = new Visifire2(\"SL.Visifire.Charts.xap\"," + sWidth + "," + sHeight + ");" + Environment.NewLine);
        sb.Append("      vChart.setDataUri(\"getChartData2.aspx?SQLFILTER=" + Server.UrlEncode(Chart2SQL) + "&LEGEND=" + meta.LegendText + "\");" + Environment.NewLine);
        sb.Append("vChart.preLoad = function(args){ var chart = args[0]; for(i=0;i<chart.Series.length;i++) chart.Series[i].MouseLeftButtonDown = MouseLeftButton_Clicked;}" + Environment.NewLine);
        sb.Append("      vChart.render(\"VisifireChart2\");" + Environment.NewLine);
        if (meta.DisplayDaily()) sb.Append("      ShowChartMonthly(false) " + Environment.NewLine);
        sb.Append("    </" + "script>" + Environment.NewLine);

        DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Trace.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + " Ended: " + duration.ToString());
        return sb.ToString();
    }


    protected String URLEncode(String tmpStr)
    {
        return tmpStr.Replace("  ", " ").Trim().Replace(" ", "+");
    }


    protected void chkShowSettings_CheckedChanged(object sender, EventArgs e)
    {

    }


}